package com.example.partner.fragment.team;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.example.partner.R;
import com.example.partner.activity.ChatActivity;
import com.example.partner.common.BaseResponse;
import com.example.partner.common.TeamInfoViewModel;
import com.example.partner.common.UserInfoViewModel;
import com.example.partner.model.domain.User;
import com.example.partner.service.UserService;
import com.google.android.flexbox.FlexboxLayout;

import org.json.JSONArray;
import org.json.JSONException;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class TeamAnnounceFragment extends Fragment {
    TextView announce;
    private TeamInfoViewModel viewModel;


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // 加载布局文件
        return inflater.inflate(R.layout.fragment_team_announce, container, false);

    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        // 获取与 Fragment 关联的 Activity 的 SharedPreferences
        SharedPreferences sharedPreferences = getActivity().getSharedPreferences("CurrentUser", Context.MODE_PRIVATE);
        Long userId = sharedPreferences.getLong("userId", -1);
        // 在这里初始化 UI 组件
        announce = view.findViewById(R.id.teamannounce);
        viewModel = new ViewModelProvider(requireActivity()).get(TeamInfoViewModel.class);
        announce.setText(viewModel.getAnnounce());

    }
}
